require(['./config'],() => {
    require(['request','template','header','footer'],(req,template) => {
        class List{
            constructor(){
                this.getProdId()
                // this.getLeftData()
            }
            getProdId(){
                //通过地址栏拿到prodid然后发送请求
                // console.log(window)
                // let str = window.location.search  //prodId = 5
                // str = str.split("=")[1]
                const str = window.location.search.split('=')[1]
                // console.log(str)
                this.getListData(str)
            }
            getListData(prodId){
                req.getListProdData(prodId)
                    .then(res => {
                        // console.log(res)
                        const{ categories,items} = res.data  //const categories = res.data.categories
                        this.createTabs(categories)
                        this.createList(items)
                    })
            }
            createTabs(categories){
                // console.log(categories)
                $('.container .concent-left .c-f-o').html(template('listTabsTemplate',{categories}))
                // console.log($('.container .concent-left .c-f-o'))
            }
            createList(prodList){
                // console.log(prodList)
                const { list } = prodList
                $('#sports').html(template('prodListTemplate',{list}))
            }
            // getLeftData(){
            //     req.getProdLeftData()
            //     .then(res => {
            //         if(res.code === 200){
            //             const leftData = res.data.category.id 
            //             // console.log(leftData)
            //             $('.container .concent-left .c-f-o').html(template('listTabsTemplate',{categories:leftData}))
            //         }
            //     })
            // }
        }
        return new List()
    })
})